<template>
  <el-dialog :title="dTitle" :visible.sync="visible" width="40%" :before-close="closeDialog">
    <el-form :model="form">
      <el-form-item label="到账账户" :label-width="formLabelWidth">
       <span>微信零钱</span>
      </el-form-item>
      <el-form-item label="到账实名" :label-width="formLabelWidth">
        <el-input v-model="form.name" auto-complete="off" placeholder=" 请输入绑定微信支付的实名"></el-input>
      </el-form-item>
      <el-form-item label="提现金额" :label-width="formLabelWidth">
        <el-input v-model="form.money" auto-complete="off" placeholder="￥"></el-input>
      </el-form-item>
      <div class="bottom">当前可提现金额￥{{tabledata.gotocash}}</div>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="closeDialog()">取 消</el-button>
      <el-button type="primary" @click="submit">确认提现</el-button>
    </div>
  </el-dialog>
</template>

<script>
export default {
  props: {
    dTitle: {
      type: String,
      default: ""
    },
    visible: {
      type: Boolean,
      default: false
    },
    formData: {
      type: Object,
      default: {}
    },
    tabledata: {
        type:Object,
        default: {}
    }
    
  },
  data() {
    return {
      form: {},
      formLabelWidth: "100px"
    };
  },
  watch: {
    formData(newVal, oldVal) {
      console.log(newVal, oldVal);
      if (newVal) {
        this.form = { ...newVal };
      }
    }
  },
  methods: {
    submit() {
      // 更新部门信息的接口
      if (this.form.id) {
        updateDepartment({
          money: this.form.money,
          name: this.form.name,
        }).then(res => {
          if (res.success) {
            this.closeDialog('reload')
            // 重新获取数据
            // this.getTableDatas();
          }
        });
      } else {
        addDepartment({//调用
           money: this.form.money,
          name: this.form.name,
        }).then(res => {
          if (res.success) {
           
            this.closeDialog('reload')
          }
        });
      }
    },
    closeDialog(reload) { //子传父
      this.$emit("closeDialog", reload);
    }
  }
};
</script>

<style scoped>
.bottom{
    width: 100%;
    text-align: center;
}
</style>